package com.zhang.postgresql.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhang.postgresql.common.entity.UserBaseDO;
import com.zhang.postgresql.dao.UserBaseMapper;
import com.zhang.postgresql.service.IUserBaseService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
 * description
 *
 * @author zhangFanJun
 * @date 2024-03-29 17:49
 **/
@RequiredArgsConstructor
@Slf4j
@Service
public class UserBaseService extends ServiceImpl<UserBaseMapper, UserBaseDO> implements IUserBaseService {

    @Override
    public String get() {

        log.info("postgresql ======》");
        UserBaseDO one = new UserBaseDO();
        one.setId(ThreadLocalRandom.current().nextInt());
        one.setUsername(one.getId().toString());
        one.setCreateTime(new Date());
        this.save(one);

        List<UserBaseDO> list = this.list();
        list.forEach(x->{
            log.info("读取到的数据：{}",x);
        });

        return "访问完成";
    }
}
